home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- template <class T>
- static void control_all(T *l)
- {
- int kill;
- T *n;
-
- for (T *o = l; o != 0; o = n)
- {
- // Control object
-
- kill = !o->control();
-
- // Get next pointer
-
- n = (T *)o->next;
-
- // Check if object has to be removed
-
- if (kill)
- delete o;
- }
- }
-
- static void control_with_dirty(cGameObject *l)
- {
- int kill;
- cGameObject *n;
-
- for (cGameObject *o = l; o != 0; o = n)
- {
- // Save old locations
-
- int x1 = o->x1, y1 = o->y1, x2 = o->x2, y2 = o->y2;
-
- // Control object
-
- kill = !o->control();
-
- // Get next pointer
-
- n = (cGameObject *)o->next;
-
- // Check if object has to be removed
-
- if (kill)
- {
- // If object moved make old spot dirty
-
- if (x1 != o->x1 || y1 != o->y1 || x2 != o->x2 || y2 != o->y2)
- o->surface->add_dirty(x1, y1, x2, y2);
-
- // Delete will make area currently occupied dirty
-
- delete o;
- }
- else if (o->is_dirty() || x1 != o->x1 || y1 != o->y1 || x2 != o->x2 || y2 != o->y2)
- {
- // Make rectangles dirty
-
- o->surface->add_dirty(x1, y1, x2, y2);
- o->surface->add_dirty(o->x1, o->y1, o->x2, o->y2);
- }
- }
- }
-
- void control_level()
- {
- // Make random things
-
- cBubble::make();
-
- // First everything except players
-
- control_with_dirty(scenery_back1);
- control_with_dirty(scenery_back2);
- control_with_dirty(scenery_game1);
- control_with_dirty(scenery_game2);
- control_with_dirty(scenery_game3);
- control_with_dirty(structures);
- control_with_dirty(stairs);
- control_with_dirty(bubbles);
- control_with_dirty(bonus);
- control_with_dirty(weapons);
-
- control_with_dirty(disaster);
- control_with_dirty(parts);
- control_with_dirty(effects);
-
- // Players and their scores last
-
- control_with_dirty(players);
- control_all(scores);
- }
-